package com.neuedu.controller.dept;

import com.neuedu.factory.ClassFactory;
import com.neuedu.service.AddDeptService;
import com.neuedu.service.TableService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet(name = "AddDeptServlet", urlPatterns = "/his/adddept")
public class AddDeptServlet extends HttpServlet {
    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String num = request.getParameter("num");
        String name = request.getParameter("name");
        String deptclassity = request.getParameter("deptclassity");
        String depttype = request.getParameter("depttype");
        Object[] objs={num,name,deptclassity,depttype};
        AddDeptService ads = (AddDeptService) ClassFactory.createObj("AddDeptService");
        int flag=ads.addDeptment(objs);
        String rs="";
        if (flag>=1){
            rs = "true";
        }else{
            rs = "false";
        }
        response.getWriter().append(rs);
    }

    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doPost(request,response);
    }
}
